package com.lanchetech.dao;

import com.lanchetech.bean.request.PageReq;
import com.lanchetech.bean.vo.UserTreeListVO;
import com.lanchetech.entity.Tree;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface TreeMapper {
    int deleteByPrimaryKey(Long id);

    int insert(Tree record);

    int insertSelective(Tree record);

    Tree selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(Tree record);

    int updateByPrimaryKey(Tree record);

    List<Tree> findAllByUserId(@Param("userId") Long userId);

    List<Tree> findAllByUserIdAndIsExchange(@Param("userId") Long userId, @Param("isExchange") Byte isExchange);

    Integer getUserTreeNumber(@Param("userId") Long userId);

    List<UserTreeListVO> findAllPage(PageReq req);

    int updateIsActiveByIdAndUserId(@Param("updatedIsActive") Byte updatedIsActive, @Param("id") Long id, @Param("userId") Long userId);


    Tree selectOneByUserIdAndIsActive(@Param("userId") Long userId, @Param("isActive") Byte isActive);

    int updateIsActiveByUserId(@Param("updatedIsActive") Byte updatedIsActive, @Param("userId") Long userId);

    int updateIsExchangeByIdAndUserId(@Param("updatedIsExchange") Byte updatedIsExchange, @Param("id") Long id, @Param("userId") Long userId);

    Tree findOneByUserIdAndIsExchange(@Param("userId")Long userId,@Param("isExchange")Byte isExchange);


}